package com.usv.drawer.impl;

import com.usv.comparepic.Point;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import com.usv.drawer.DifferenceDrawer;

public class DifferenceFileDrawer implements DifferenceDrawer {

	public void drawDifference(BufferedImage bufImgResult, Point start,
								Point end, Color color) {
		int x1 = start.getX();
                int x2 = end.getX();
                int y1 = start.getY();
                int y2 = end.getY();
                
		Graphics graphics = bufImgResult.getGraphics();
		graphics.setColor(color);

		graphics.drawRect(x1, y1, x2 - x1, y2 - y1);
		
		try {
			ImageIO.write(bufImgResult, "png", new File("image.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}